<template>
  <div class="page-container">
    <SecondSearch></SecondSearch>
      <el-main>
          <el-row :gutter="20">
            <el-col v-for="(item, index) in products" :key="index" :span="8">
              <div class="product">
                  <el-image :src="item.image"></el-image>
                <div class="info">
                  <div class="name-price">
                    <div class="name">{{ item.name }}</div>
                    <div class="price">{{ item.price }}￥</div>
                  </div>
                  <div class="buy-button">
                    <el-button type="primary" @click="buyItem(item)">购买</el-button>
                  </div>
                </div>
              </div>
            </el-col>
          </el-row>
      </el-main>
  </div>
</template>

<script>
import SecondSearch from "@/views/secondHandMarket/SecondSearch.vue";
export default {
  name: "secondIndex",
  components:{
    SecondSearch
  },
  data() {
    return {
      products: [
        {
          name: "商品1",
          price: "100",
          image: "https://img2.baidu.com/it/u=2565362953,3043166123&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500"
        },
        {
          name: "商品2",
          price: "200",
          image: "https://img2.baidu.com/it/u=2565362953,3043166123&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500"
        },
        {
          name: "商品3",
          price: "300",
          image: "https://img2.baidu.com/it/u=2565362953,3043166123&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500"
        },
        {
          name: "商品3",
          price: "300",
          image: "https://img2.baidu.com/it/u=2565362953,3043166123&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500"
        },
        {
          name: "商品3",
          price: "300",
          image: "https://img2.baidu.com/it/u=2565362953,3043166123&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500"
        },
      ]
    };
  },
  methods: {
    buyItem(item) {
      // 处理购买逻辑
      console.log("购买商品", item);
    },
  }
};
</script>

<style scoped>
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}
.product {
  text-align: center;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 5px;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: background 0.3s;
  margin: 10px;
  width: 300px;
}
.product:hover {
  background: #ebebeb;
}
.el-image{
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}
.info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding: 10px;
}
.name-price {
  flex: 1;
  text-align: left;
}
.name {
  font-size: 16px;
  font-weight: bold;
}
.price {
  margin-top: 5px;
  font-size: 14px;
  color: #999;
}
.buy-button {
  margin-left: 10px;
}
</style>
